package com.wbase.base.app

import android.app.Application
import android.content.Context
import android.content.res.Resources
import androidx.annotation.StringRes
import com.alibaba.android.arouter.launcher.ARouter

/**
 * 全局Context或者全局资源获取
 *
 * @author wangheng
 */
object App{
    private lateinit var mContext: Application
    private var mDebug = true

    // 渠道号
    private var mChannel: String? = null

    fun init(context: Application, debug: Boolean){
        mContext = context
        mDebug = debug
    }

    fun getContext(): Context {
        return mContext
    }

    fun getApplication(): Application {
        return mContext
    }

    fun isDebug(): Boolean {
        return mDebug
    }

    fun getString(@StringRes id: Int): String {
        return mContext.getString(id)
    }

    fun getResources(): Resources {
        return mContext.resources
    }

    fun getChannel(): String {
        return "GP"
    }


    const val KEY_MAIN_ACTION = "key_home_action"
    const val MAIN_ACTION_DEFAULT = 1
    const val MAIN_ACTION_EXIT = 2
    const val MAIN_ACTION_LOGIN = 3
    const val MAIN_ACTION_LOGIN_FROM_LOGOUT = 4

    fun backToMain(action: Int = MAIN_ACTION_DEFAULT){
        ARouter.getInstance().build("/main/main")
            .withInt(KEY_MAIN_ACTION,action)
            .navigation()
    }
}